import React, { useEffect, useRef } from "react";
import C from './Class'
const App = () => {
  //三种绑定方式
  //1.React.createRef()
  //   const ref_obj=React.createRef()
  const ref_obj = useRef();

  //2.回调函数
  const ref = (e) => {
    //给元素直接绑定焦点事件
    //函数方式,立即执行,不给调用机会
    e.focus();
  };
  //3.字符串[历史写法,用于class组件]
  useEffect(() => {
    console.log(ref_obj);
    ref_obj.current.focus();
  }, []);
  return (
    <div style={{ marginLeft: "20px" }}>
      <input type="text" ref={ref_obj} style={{ padding: "5px" }} />
      {/* <input type="text" ref={ref} /> */}
      <C></C>
    </div>
  );
};

export default App;
